﻿package mortal.game.manager
{
    import flash.display.*;
    import flash.utils.*;
    import mortal.game.manager.mouse.*;

    public class MouseRuleManager extends Object
    {
        private static var _dcObjRule:Dictionary = new Dictionary();

        public function MouseRuleManager()
        {
            return;
        }// end function

        public static function addRule(param1:InteractiveObject, param2:Class, param3:Function = null) : void
        {
            var _loc_4:* = getRuleObj(param1, param2);
            if (_loc_4.obj)
            {
                return;
            }
            var _loc_5:* = new param2 as IMouseRule;
            _loc_5.target = param1;
            _loc_5.addCall(param3);
            _loc_5.startRule();
            _loc_4.ruleClass = param2;
            _loc_4.obj = param1;
            _dcObjRule[_loc_4] = _loc_5;
            return;
        }// end function

        public static function removeRule(param1:InteractiveObject, param2:Class) : void
        {
            var _loc_3:* = getRuleObj(param1, param2);
            if (!_loc_3.obj)
            {
                return;
            }
            var _loc_4:* = _dcObjRule[_loc_3];
            if (_loc_4)
            {
                _loc_4.endRule();
            }
            delete _dcObjRule[_loc_3];
            return;
        }// end function

        public static function getRuleObj(param1:InteractiveObject, param2:Class) : RuleObj
        {
            var _loc_3:* = undefined;
            var _loc_4:RuleObj = null;
            for (_loc_3 in _dcObjRule)
            {
                
                if (_loc_3 is )
                {
                    _loc_4 = _loc_3 as ;
                    if (_loc_4.obj == param1 && _loc_4.ruleClass == param2)
                    {
                        return _loc_4;
                    }
                }
            }
            return new RuleObj();
        }// end function

    }
}

class RuleObj extends Object
{
    public var ruleClass:Class;
    public var obj:InteractiveObject;
    public var callBack:Function;

    function RuleObj()
    {
        return;
    }// end function

}

